package com.project.service.impl;

import com.project.bean.GradeBean;
import com.project.mapper.IGradeMapper;
import com.project.service.IGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
@Transactional
public class GradeServiceImpl implements IGradeService {
    @Autowired
    private IGradeMapper gradeMapper;


    @Override
    public Set<GradeBean> findAll() {
        Set<GradeBean> gradeBeanSet = new HashSet<>();
        gradeBeanSet.addAll(gradeMapper.selectList(null));
        return gradeBeanSet;
    }

    @Override
    public Set<GradeBean> findByRoleArray(Integer[] roleArray) {
        Set<GradeBean> gradSet = new HashSet<>();
        for (Integer integer : roleArray) {
            List<GradeBean> list = gradeMapper.findByRoleId(integer);
            gradSet.addAll(list);
        }

        return gradSet;
    }
}
